package redisInit

import (
	"fmt"
	"github.com/go-redis/redis"
	"hotel/appconfig"
)

var Rdb *redis.Client

func RedisInit() {
	appConf := appconfig.AppConf.Redis
	fmt.Println(appConf)
	Rdb = redis.NewClient(&redis.Options{
		Addr:     appConf.Host,
		Password: appConf.Password,
		DB:       appConf.Db,
	})
	fmt.Println(Rdb)
	err := Rdb.Ping().Err()
	if err != nil {
		fmt.Println("Redis连接失败")
		return
	}
	fmt.Println("Redis连接成功")
}
